﻿﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>排产生产准备管控</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <link rel="stylesheet" href="/InSiteWebApplication/Content/webuploader/webuploader.css" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
        #ApsPoolForm{padding:10px 0px;}
        .priority{margin:0 10px;}
       .fontRight{text-align:right;padding:5px 0;display: grid}
        
    </style>
</head>
<body>
    <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>工区</td>
                    <td>零件号</td>
                    <td>批次号</td>
                    <td>订单号</td>
                    <td>批次状态</td>
                    <td>是否暂停</td>
	    		</tr>
                <tr class="divLabel">
                    <td><input id="Workcenter" name="Workcenter" class="easyui-combobox" style="width: 150px; height: 22px" data-options='editable:false,multiple:true'/></td>
                    <td><input id="Text14" name="ProductName" class="easyui-textbox" style="width: 150px; height: 22px"/></td>
                    <td><input id="Text15" name="ContainerNo" class="easyui-textbox" style="width: 150px; height: 22px"/></td>
                    <td><input id="Text16" name="MfgOrderName" class="easyui-textbox" style="width: 150px; height: 22px"/></td>
                    <td><input id="ContainerStatus" name="ContainerStatus" class="easyui-combobox" style="width: 150px; height: 22px"/></td>
                    <td><input id="IsHold" name="IsHold" class="easyui-combobox" style="width: 150px; height: 22px"/></td>
                </tr >
                <tr class="divLabel">
                    <td>订单要求开始</td>
                    <td>订单要求完成</td>
                    <td>批次计划开始</td>
                    <td>批次计划完成</td>
                    <td>是否齐套</td>
                    <td rowspan="2"><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
                    <td rowspan="2"></td>
                </tr>
	    		<tr class="divLabel">
	    			<td><input name="MfgOrderStartTime" class="easyui-datebox" style="width: 150px; height: 22px"/></td>
                    <td><input name="MfgOrderFinshTime" class="easyui-datebox" style="width: 150px; height: 22px" /></td>
                    <td><input name="ContainerStartTime" class="easyui-datebox" style="width: 150px; height: 22px" /></td>
                    <td><input name="ContainerFinshTime" class="easyui-datebox" style="width: 150px; height: 22px"/></td>
                    <td>
                        <input class="easyui-radiobutton IsComp1" labelAlign="right" labelWidth="30px" name="IsComp" value="1" label="是" checked>
                        <input class="easyui-radiobutton IsComp" labelAlign="right" labelWidth="30px" name="IsComp" value="0" label="否">
                    </td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>

    <div class="panelSection">    
        <div class="easyui-panel " title="生产准备管控" style="padding:3px;width: 100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
                <table id="ApsProducePreTable" style="height:400px;width: 100%" data-options="rownumbers:true,toolbar:'#tb'"></table>
                <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            group:'paging-tail-btns',
                            id:'pageGo'
                    }]
                    ">
                    </div>
                    <div id="tb" style="padding:5px;height:auto">
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.statusFreshen()">状态刷新</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.dispatchEdit()">批量编辑</a>
                    </div>
        </div>
      </div>
    <div class="panelSection">    
        <div id="tabs" class="easyui-tabs">
                <div title="原材料" style="padding:10px;">
                    <div style="color:Red;padding: 0px 10px 10px;">根据ERP缺料报表判断，无缺料即齐套</div>
		            <table id="MaterialTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="集件"  style="overflow:auto;padding:10px;display:none;">
                   <div style="color:Red;padding: 0px 10px 10px;">根据ERP缺料报表判断，无缺料即齐套</div>
		           <table id="IssueTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="夹模具" style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">根据ERP工装工具台账判断，数量满足即齐套</div>
		           <table id="SpecialTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="刀具"  style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">根据ERP工装工具台账判断，数量满足即齐套</div>
		           <table id="CutTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="量具"  style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">根据ERP工装工具台账判断，数量满足即齐套</div>
		           <table id="MeasureTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="辅材"  style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">根据MES内辅材库存台账判断，库存台账有可用数量且有效期大于结束时间则判断为是</div>
		           <table id="AuxMaterialTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="数控程序"  style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">只显示PDM推送的【是否数控序】为是的工序，数控名称为空则齐套判断为否</div>
		           <table id="ControlTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
                <div title="特殊过程"  style="padding:10px;display:none;">
                    <div style="color:Red;padding: 0px 10px 10px;">只显示PDM推送的【是否特殊过程序】为是的数据，特殊过程有效期晚于计划结束时间则标记为否</div>
		           <table id="SpotcheckTable" style="height:240px" data-options="rownumbers:true"></table>
                </div>
            </div>
      </div>
     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
    <div id="dd" style="display:none">
         <div id="EditForm" style="margin: 0 auto;display: table;padding-top: 15px" >
            <table>
                <tr >
                   <td>是否齐套</td><td><input id="IsComp" name="IsComp" class="easyui-combobox" style="width: 150px; height: 22px"/></td>
                </tr>
                 <tr>
                   <td>标记方式</td><td><input id="MarkMethod" name="MarkMethod" class="easyui-combobox" style="width: 150px; height: 22px"/></td>
                </tr>
                 <tr>
                    <td colspan="2" style="text-align:right;padding-top:10px">
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.saveDispatchEdit()">确定</a>
                        <a href="javascript:void(0)" class="easyui-linkbutton" onclick="$('#dd').dialog('close')">取消</a>
                    </td>
                </tr>
            </table>
         </div>
    </div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/array.pollyfill.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script>
    //创建人：longb
    //日期：2023-03-22
    //描述：排产生产准备管控
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/ApsHandler/ApsProducePrepaHandler.ashx",
        init: function () {
            page.initPageData();
            page.initCombobox();
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        initPageData: function () {
            page.post({ action: "InitPageData" }, true, function (res) {
                $('#Workcenter').combobox({
                    valueField: 'WORKCENTERID',
                    textField: 'WORKCENTERNAME',
                    panelHeight: 200,
                    data: res.DBTable, //下拉数据
                    onSelect: function (row) {
                        var opts = $(this).combobox('options');
                        var el = opts.finder.getEl(this, row[opts.valueField]);
                        el.find('input.combobox-checkbox')._propAttr('checked', true);
                    },
                    onUnselect: function (row) {
                        var opts = $(this).combobox('options');
                        var el = opts.finder.getEl(this, row[opts.valueField]);
                        el.find('input.combobox-checkbox')._propAttr('checked', false);
                    },
                    formatter: function (row) {
                        var opts = $(this).combobox('options');
                        return '<input type="checkbox" class="combobox-checkbox">' + row[opts.textField] + '</input>';
                    }
                });
            });
        },
        initCombobox: function () {
            $('#ContainerStatus').combobox({
                data: [{ id: '1', text: '在制品' }, { id: '0', text: '新开卡' }, { id: '', text: '全部'}],
                valueField: 'id',
                textField: 'text',
                value: '',
                panelHeight: 100
            });
            $('#IsComp').combobox({
                data: [{ id: '0', text: '否' }, { id: '1', text: '是'}],
                valueField: 'id',
                textField: 'text',
                value: '1',
                panelHeight: 100
            });
            $('#MarkMethod').combobox({
                data: [{ id: '0', text: '手动' }, { id: '1', text: '自动'}],
                valueField: 'id',
                textField: 'text',
                value: '0',
                panelHeight: 100
            });
            $('#IsHold').combobox({
                data: [{ id: '0', text: '否' }, { id: '1', text: '是'}],
                valueField: 'id',
                textField: 'text',
                value: '0',
                panelHeight: 100
            });
            $('.IsComp1').radiobutton('check');
        },
        gridTableCellStyler: function (value) {
            if (value == 0) { return 'background-color:rgb(236, 128, 141)'; } else { return 'background-color:rgb(149, 242, 2)'; }
        },
        gridTableCellFormatter: function (value) {
            if (value == 0) { return 'x'; } else { return '√'; }
        },
        //页面事件绑定
        bind: function () {
            $('#ApsProducePreTable').datagrid({
                checkOnSelect: false,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
                frozenColumns: [[
                 { field: 'PK', checkbox: true, width: 120, align: 'center' },
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP) } },
                 { field: 'APSSEQUENCE', title: '优先级', width: 70, align: 'center' }, //排产顺序号
                 {field: 'MFGORDERNAME', title: '订单号', width: 120, align: 'center' },
                 { field: 'PRODUCTDESC', title: '零件号', width: 120, align: 'center' },
                 { field: 'CONTAINERNAME', title: '批次号', width: 120, align: 'center' },
                ]],
                columns: [[
                 { field: 'FAMILYLISTNAMES', title: '型别', width: 100, align: 'center' },
                 { field: 'CONTAINERTYPE', title: '批次类型', width: 70, align: 'center', formatter: function (value, row, index) { if (value == "2") { return '批量加工'; } else if (value == "3") { return '批量带子序号'; } else if (value == "7") { return '单件加工' } else { return '未知'; } } },
                 { field: 'CONTAINERSTATUS', title: '批次状态', width: 70, align: 'center', formatter: function (value, row, index) { if (value == "1") { return '在制'; }  else if (value == "0") { return '新开卡'; } else { return '未知'; } } },
                 { field: 'WORKFLOWSTEPNAME', title: '当前工序', width: 140, align: 'center' },
                 { field: 'WORKFLOWINFO', title: '工艺版次', width: 120, align: 'center' },
                 { field: 'QTY', title: '在制数量', width: 80, align: 'center' },
                 { field: 'MFGSTARTDATE', title: '要求开始', width: 100, align: 'center' },
                 { field: 'STARTTIME', title: '计划开始', width: 100, align: 'center' },
                 { field: 'MFGENDDDATE', title: '要求完成', width: 100, align: 'center' },
                 { field: 'ENDTIME', title: '计划完成', width: 100, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISMATERIAL', title: '原材料', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISISSUE', title: '集件', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISSPECIAL', title: '夹磨具', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISCUT', title: '刀具', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISMEASURE', title: '量具', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISAUXMATERIAL', title: '辅材', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISCONTROL', title: '数控程序', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'ISSPOTCHECK', title: '特殊过程', width: 70, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(value) }, styler: function (value, row, index) { return page.gridTableCellStyler(value) } },
                 { field: 'MARKTYPE', title: '标记方式', width: 70, align: 'center', formatter: function (value, row, index) { if (value == 0) { return '手动'; } else { return '自动'; } } },
                 { field: 'XXX', title: '', width: 30 }
                ]],
                onSelect: function (index, row) {
                    page.getApsProducePrepDetailData();
                },
                onUnselect: function (index, row) {
                    page.getApsProducePrepDetailData();
                }
            });
            $("#MaterialTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'MATERIALTRADEMARK', title: '材料牌号', width: 100, align: 'center' },
                 { field: 'SFS', title: '实发数量/顺序号', width: 100, align: 'center' },
                 { field: 'LABSTQ', title: '缺料数', width: 90, align: 'center' },
                 { field: 'RLH', title: '熔炉号', width: 90, align: 'center' },
                 { field: 'JYBH', title: '检验编号', width: 80, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#IssueTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'PRODUCTNAME', title: '零部件号', width: 100, align: 'center' },
                 { field: 'PRODUCTCHILDNO', title: '零部件批次', width: 100, align: 'center' },
                 { field: 'QTYREQUIRED', title: '需求数', width: 90, align: 'center' },
                 { field: 'LABSTQ', title: '缺料数', width: 90, align: 'center' },
                 { field: 'OLDPRODUCTNAME', title: '原物料号', width: 80, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#SpecialTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'TOOLNAME', title: '工具编号', width: 100, align: 'center' },
                 { field: 'DESCRIPTION', title: '工具名称', width: 100, align: 'center' },
                 { field: 'RESOURCETYPENAME', title: '工具类型', width: 90, align: 'center' },
                 { field: 'QTY', title: '需求数', width: 90, align: 'center' },
                 { field: 'MENGE', title: '可用数', width: 80, align: 'center' },
                 { field: 'LABSTALL', title: '库存数', width: 100, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#CutTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'TOOLNAME', title: '工具编号', width: 100, align: 'center' },
                 { field: 'DESCRIPTION', title: '工具名称', width: 100, align: 'center' },
                 { field: 'RESOURCETYPENAME', title: '工具类型', width: 90, align: 'center' },
                 { field: 'QTY', title: '需求数', width: 90, align: 'center' },
                 { field: 'MENGE', title: '可用数', width: 80, align: 'center' },
                 { field: 'LABSTALL', title: '库存数', width: 100, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#MeasureTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'TOOLNAME', title: '工具编号', width: 100, align: 'center' },
                 { field: 'DESCRIPTION', title: '工具名称', width: 100, align: 'center' },
                 { field: 'RESOURCETYPENAME', title: '工具类型', width: 90, align: 'center' },
                 { field: 'QTY', title: '需求数', width: 90, align: 'center' },
                 { field: 'MENGE', title: '可用数', width: 80, align: 'center' },
                 { field: 'LABSTALL', title: '库存数', width: 100, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#AuxMaterialTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'AUXMATERIALNAME', title: '辅材编码', width: 100, align: 'center' },
                 { field: 'ACCOUNTQTY', title: '台账数量（单位）', width: 120, align: 'center' },
                 { field: 'INDATE', title: '有效期', width: 90, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#ControlTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'NCNUMBER', title: '是否数控序', width: 90, align: 'center' },
                 { field: 'NCNUMBERNAME', title: '数控程序名称', width: 80, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });
            $("#SpotcheckTable").datagrid({
                columns: [[
                 { field: 'ISMARK', title: '标识', width: 40, align: 'center', formatter: function (value, row, index) { return page.gridTableCellFormatter(row.ISCOMP == '是' ? 1 : 0) }, styler: function (value, row, index) { return page.gridTableCellStyler(row.ISCOMP == '是' ? 1 : 0) } },
                 { field: 'SPECNO', title: '工序号', width: 90, align: 'center' },
                 { field: 'SPECNAME', title: '工序名称', width: 140, align: 'center' },
                 { field: 'STEPSTARTTIME', title: '开始时间', width: 150, align: 'center' },
                 { field: 'STEPENDTIME', title: '结束时间', width: 150, align: 'center' },
                 { field: 'SPECIALCOURSESPECREPORTNO', title: '特殊过程确认编号', width: 120, align: 'center' },
                 { field: 'INDATE', title: '有效期', width: 150, align: 'center' },
                 { field: 'ISCOMP', title: '是否齐套', width: 80, align: 'center' }
                 ]]
            });

            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getApsProducePrepData();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getApsProducePrepData();
            });
            //清除按钮
            $('#btnReset').on("click", function () {
                page.reset(true, true);
                page.pageNumber = 1; page.pagetotal = 0
                $('#pp').pagination('refresh', {
                    total: page.pagetotal,
                    pageSize: page.pageSize,
                    pageNumber: page.pageNumber
                });
            });
        },
        //查询
        searchData: function () {
            clearMessage();
            page.pageNumber = 1;
            page.getApsProducePrepData();
            page.clearApsProducePrepDetailTableData();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            page.initCombobox();
            page.clearApsProducePrepDetailTableData();
            clearMessage();
        },
        //状态刷新
        statusFreshen: function () {
            var rows = $('#ApsProducePreTable').datagrid('getChecked');
            if (rows.length == 0) { displayMessage('请勾选至少一条记录再进行操作', false); return; }
            page.post({ action: "statusFreshen", mdata: JSON.stringify(rows) }, true, function (res) {
                if (res.Result) {
                    page.getApsProducePrepData();
                }
                displayMessage(res.Message, res.Result);
            });
        },
        //批量编辑
        dispatchEdit: function () {
            var rows = $('#ApsProducePreTable').datagrid('getChecked');
            if (rows.length == 0) { displayMessage('请勾选至少一条记录再进行操作', false); return; }
            $('#dd').dialog({
                title: '批量编辑',
                width: 300,
                height: 150,
                closed: false,
                cache: false,
                modal: true
            });
        },
        //批量编辑--保存
        saveDispatchEdit: function () {
            var rows = $('#ApsProducePreTable').datagrid('getChecked');
            var data = { IsComp: $('#IsComp').combobox('getValue'), MarkMethod: $('#MarkMethod').combobox('getValue') };
            page.post({ action: "saveDispatchEdit", data: JSON.stringify(data), mdata: JSON.stringify(rows) }, true, function (res) {
                if (res.Result) {
                    page.getApsProducePrepData();
                }
                $('#dd').dialog('close');
                displayMessage(res.Message, res.Result);
            });
        },
        //查询生产准备任务信息
        getApsProducePrepData: function () {
            var frdata = $('#searchForm').serializeArray();
            var data = {};
            $.each(frdata, function () {
                data[this.name] = this.value
            });
            data.workcenter = $('#Workcenter').combobox('getValues').join(',');
            var param = {
                action: "getApsProducePrepData",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber == 0 ? 1 : page.pageNumber,
                data: JSON.stringify(data)
            };
            page.post(param, true, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#ApsProducePreTable').datagrid('loadData', res.DBTable);
                }
            });
        },
        //查询生产准备--明细信息
        getApsProducePrepDetailData: function () {
            var row = $('#ApsProducePreTable').datagrid('getSelected');
            if (row == null) { page.clearApsProducePrepDetailTableData(); return; }
            page.post({ action: "getApsProducePrepDetailData", ContainerID: row.CONTAINERID,workflowid:row.WORKFLOWID }, true, function (res) {
                if (res.Result) {
                    $('#MaterialTable').datagrid('loadData', res.DBDataSet.MaterialTable);
                    $('#IssueTable').datagrid('loadData', res.DBDataSet.IssueTable);
                    $('#SpecialTable').datagrid('loadData', res.DBDataSet.SpecialTable);
                    $('#CutTable').datagrid('loadData', res.DBDataSet.CutTable);
                    $('#MeasureTable').datagrid('loadData', res.DBDataSet.MeasureTable);
                    $('#AuxMaterialTable').datagrid('loadData', res.DBDataSet.AuxMaterialTable);
                    $('#ControlTable').datagrid('loadData', res.DBDataSet.ControlTable);
                    $('#SpotcheckTable').datagrid('loadData', res.DBDataSet.SpotcheckTable);
                }
            });
        },
        //清空所有明细数据
        clearApsProducePrepDetailTableData: function () {
            $('#MaterialTable').datagrid('loadData', []);
            $('#IssueTable').datagrid('loadData', []);
            $('#SpecialTable').datagrid('loadData', []);
            $('#CutTable').datagrid('loadData', []);
            $('#MeasureTable').datagrid('loadData', []);
            $('#AuxMaterialTable').datagrid('loadData', []);
            $('#ControlTable').datagrid('loadData', []);
            $('#SpotcheckTable').datagrid('loadData', []);
        },
        //清除方法，重要！！！
        reset: function (iscondition, isresult) {
            clearMessage();
        },
        //post数据
        post: function (param, async, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: async,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
    $(function () {
        page.init();
    });



</script>
